home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7996 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: anvil.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: newbie question concerning fread
  5. Date: 28 Feb 1996 13:33:34 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Distribution: inet
  8. Message-ID: <4h2hneINN9c2@anvil.ugrad.cs.ubc.ca>
  9. References: <rblayney.824643669@extro> <4gqejmINNh5@keats.ugrad.cs.ubc.ca> <825453118snz@genesis.demon.co.uk>
  10. NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
  11.  
  12. In article <825453118snz@genesis.demon.co.uk>,
  13. Lawrence Kirby  <fred@genesis.demon.co.uk> wrote:
  14.  >In article <4gqejmINNh5@keats.ugrad.cs.ubc.ca>
  15.  >           c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
  16.  >
  17.  >>The two are equivalent, since in C, an "E1[E2]", where E1 and E2 are
  18.  >>expressions,  is the same as *((E1) + (E2)). One neat effect of this definition
  19.  >>is that if you have an array called 'a', and an index called 'i', you can refer
  20.  >>to the ith element as either a[i] or i[a].
  21.  >
  22.  >But certainly not [a]i or [i]a
  23.  >
  24.  >>Hence both of these constructs give the letter 'x':
  25.  >
  26.  >>
  27.  >>        char x = "abcx"[3];
  28.  >>        char x = [3]"abcx";        /* This is a syntax error */
  29.  >>        char x = ["abcx"]3;        /* And so is this */
  30.  >>        char x = 3["abcx"];
  31.  
  32. That's weird. ? I clearly said "both", and then I somehow gave four things of
  33. which two are wrong.
  34.  
  35. The [] are part of the production of a postfix expression, which expects  the
  36. [] pair to _follow_ another non-terminal. In no production of the grammar can
  37. [] be followed by anything other than an operator (possibly '[' itself!) or a
  38. terminating semicolon.
  39.  
  40. I apologize for the error.
  41. -- 
  42.  
  43.